<template>
  <div class="value-page">
    <!-- 项目基本信息 -->
    <a-descriptions bordered :column="2" size="small" class="col-span-2">
      <a-descriptions-item label="项目编号">
        {{ projectAuditInfo.projectBuild.projectNo }}
      </a-descriptions-item>
      <a-descriptions-item label="项目名称">
        {{ projectAuditInfo.projectBuild.projectName }}
      </a-descriptions-item>
      <a-descriptions-item label="项目类型">
        {{ projectAuditInfo.projectBuild.subName }}
      </a-descriptions-item>
      <a-descriptions-item label="二化车间">
        {{ projectAuditInfo.projectBuildBivoltine.workshop }}
      </a-descriptions-item>
      <a-descriptions-item label="二化岗位">
        {{ projectAuditInfo.projectBuildBivoltine.post }}
      </a-descriptions-item>
      <a-descriptions-item label="岗位数量">
        {{ projectAuditInfo.projectBuildBivoltine.quantity }}
      </a-descriptions-item>
      <a-descriptions-item label="项目经理A">
        {{
          projectAuditInfo.approvalProjectManager
            ? projectAuditInfo.approvalProjectManager
            : projectAuditInfo.projectManager
        }}
      </a-descriptions-item>
      <a-descriptions-item label="项目经理B">
        {{ projectAuditInfo.projectSubManager }}
      </a-descriptions-item>
      <a-descriptions-item label="岗位现状">
        {{ projectAuditInfo.projectBuildBivoltine.postStatus }}
      </a-descriptions-item>
    </a-descriptions>

    <a-descriptions bordered :column="2" size="small" class="col-span-2" v-if="budgetList.length > 0">
      <a-descriptions-item :label="item.budgetItemName" v-for="(item, index) of budgetList" :key="index"
        >{{ item.budgetItem }}
      </a-descriptions-item>
    </a-descriptions>
    <a-descriptions bordered :column="2" size="small" class="col-span-2">
      <a-descriptions-item label="机械化">
        {{ mechanization }}
      </a-descriptions-item>
      <a-descriptions-item label="信息化">
        {{ informationize }}
      </a-descriptions-item>
    </a-descriptions>

    <a-descriptions bordered :column="1" size="small">
      <a-descriptions-item label="二化落地方法">
        {{ landingMethod }}
      </a-descriptions-item>
      <a-descriptions-item label="实施方案简述">
        {{ projectAuditInfo.projectBuildBivoltine.implementationPlan }}
      </a-descriptions-item>
      <a-descriptions-item label="预期目标">
        {{ projectAuditInfo.projectBuildBivoltine.expectedTarget }}
      </a-descriptions-item>
    </a-descriptions>
  </div>
</template>

<script>
import { getAction, postAction } from '@/api/manage'
import { getParamValFromUrl, caseToShow } from '@/utils/common.js'
export default {
  name: 'ProjectBuildBasicGF',
  components: {},
  data() {
    return {
      requrl: {
        codeInfoList: '/manage/codeInfo/list',
      },
      mechanization: '',
      informationize: '',
      landingMethod: '',
      budgetList: [],
    }
  },
  mounted() {
    this.initTcodeInfoOptions()
    this.initBudget()
  },
  props: {
    projectAuditInfo: {
      Type: Object,
      default: '',
    },
  },
  methods: {
    initBudget() {
      getAction('/projectBuildAudit/getBudgetMsgById', { id: this.projectAuditInfo.projectBuild.id }).then((res) => {
        let arr = res.result || []
        this.budgetList = []
        arr.forEach((item) => {
          let obj = {
            budgetItemName: '费用支出方',
            budgetItem: item.projectBudgetFactory,
          }
          this.budgetList.push(obj)
          let obj1 = {
            budgetItemName: '总投资计划(不含税/万元)',
            budgetItem: item.projectBudgetAmount,
          }
          this.budgetList.push(obj1)
          let obj2 = {
            budgetItemName: '设备投资（含电气，不含税/万元）',
            budgetItem: item.budgetItem2030,
          }
          this.budgetList.push(obj2)
          let obj3 = {
            budgetItemName: '基建投资(不含税/万元)',
            budgetItem: item.budgetItem10,
          }
          this.budgetList.push(obj3)
          let obj4 = {
            budgetItemName: '硬件费用（不含税/万元）',
            budgetItem: item.budgetItem40,
          }
          this.budgetList.push(obj4)
          let obj5 = {
            budgetItemName: '软件费用(不含税/万元)',
            budgetItem: item.budgetItem50,
          }
          this.budgetList.push(obj5)
        })
      })
    },
    caseToShow(obj) {
      return caseToShow(obj)
    },
    initTcodeInfoOptions() {
      let mechanizationValue = ''
      let informationizeValue = ''
      let landingMethodValue = ''
      let mechanizationArr = []
      let informationizeArr = []
      let landingMethodArr = []
      if (this.projectAuditInfo.projectBuildBivoltine.mechanization) {
        mechanizationValue = this.projectAuditInfo.projectBuildBivoltine.mechanization.split(',')
      }
      if (this.projectAuditInfo.projectBuildBivoltine.informationize) {
        informationizeValue = this.projectAuditInfo.projectBuildBivoltine.informationize.split(',')
      }
      if (this.projectAuditInfo.projectBuildBivoltine.landingMethod) {
        landingMethodValue = this.projectAuditInfo.projectBuildBivoltine.landingMethod.split(',')
      }

      var vm = this
      getAction(this.requrl.codeInfoList, { type: '二化机械化原因', pageNo: 1, pageSize: 9999, isdel: 0 })
        .then((res) => {
          if (res.code == 200) {
            var list = res.result
            if (list != null) {
              list.records.map((item) => {
                console.log(mechanizationValue.indexOf(item.code))
                if (mechanizationValue.indexOf(item.code) > -1) {
                  mechanizationArr.push(item.name)
                }
              })
              vm.mechanization = mechanizationArr.join('，')
            }
          } else {
            this.$message.warning('查询二化机械化原因失败:' + res.message)
          }
        })
        .catch((res) => {
          this.$message.warning('查询二化机械化原因失败:' + res.message)
        })

      getAction(this.requrl.codeInfoList, { type: '二化信息化原因', pageNo: 1, pageSize: 9999, isdel: 0 })
        .then((res) => {
          if (res.code == 200) {
            var list = res.result
            if (list != null) {
              list.records.map((item) => {
                if (informationizeValue.indexOf(item.code) > -1) {
                  informationizeArr.push(item.name)
                }
              })
              vm.informationize = informationizeArr.join('，')
            }
          } else {
            this.$message.warning('查询二化信息化原因失败:' + res.message)
          }
        })
        .catch((res) => {
          this.$message.warning('查询二化信息化原因失败:' + res.message)
        })

      getAction(this.requrl.codeInfoList, { type: '二化落地方法', pageNo: 1, pageSize: 9999, isdel: 0 })
        .then((res) => {
          if (res.code == 200) {
            var list = res.result
            if (list != null) {
              list.records.map((item) => {
                if (landingMethodValue.indexOf(item.code) > -1) {
                  landingMethodArr.push(item.name)
                }
              })
              vm.landingMethod = landingMethodArr.join('，')
            }
          } else {
            this.$message.warning('查询二化落地方法失败:' + res.message)
          }
        })
        .catch((res) => {
          this.$message.warning('查询二化落地方法失败:' + res.message)
        })
    },
  },
}
</script>
<style lang="less" scoped>
/deep/.ant-checkbox-disabled + span {
  color: black;
}
.project-info {
  color: black;
  .info-detail {
    background-color: #fff;
    border: 1px solid #ebebeb;
    padding: 1% 2.5%;
    margin-bottom: 15px;
    position: relative;
    font-size: 16px;
    > span {
      display: inline-block;
      margin-left: 15px;
    }
    .list-title {
      font-weight: 900;
      height: unset;
      line-height: 28px;
    }
    .row-content {
      display: flex;
      align-items: baseline;
      > span {
        white-space: normal;
      }
    }
    .info-list {
      padding: unset;
      display: flex;
      flex-wrap: wrap;
      margin-bottom: 0;
      > li {
        width: 33.33%;
        padding: 3px 0;
        height: auto;
        display: flex;
        align-items: center;
        // >img{
        //   margin-right: 5px;
        // }
        .comment {
          white-space: pre-wrap;
        }
        span {
          // line-height: 1.2;
        }
      }
      .left {
        display: flex;
        align-items: baseline;
      }
      .one-row {
        width: 100%;
        align-items: baseline;
        height: auto;
        padding: 3px 0px;
        > span {
          width: calc(100% - 170px);
        }
      }
    }
    .info-content {
      .content-title {
        display: flex;
        align-items: center;
        font-weight: 900;
        img {
          margin-right: 5px;
        }
      }
      .content-box {
        padding: 5px 16px 0;
      }
    }
  }
}
</style>